Reduce number of leaks in realtime tracking mode on Garmins to zero.
authorrobertl <robertl>
Mon, 6 Nov 2006 22:01:35 +0000 (22:01 +0000)
committerrobertl <robertl>
Mon, 6 Nov 2006 22:01:35 +0000 (22:01 +0000)
Makefile.in
garmin.c
jeeps/gpsapp.c
jeeps/gpslibusb.c
kml.c
main.c

index fcfc1a08ba112b977a6940b708f6079535ee03ab..b73fd820b59b9ae89b919cb6f42735fc169d96a5 100644 (file)
@@ -155,6 +155,7 @@ dep:
        echo Edit Makefile.in and bring in /tmp/dep
 
 $(WEB)/htmldoc-$(DOCVERSION)/readme.html: FORCE
+       mkdir -p $(WEB)/htmldoc-$(DOCVERSION)
        perl xmldoc/makedoc
        xmlwf xmldoc/readme.xml         #check for well-formedness
        xmllint --noout --valid xmldoc/readme.xml       #validate
index c696357b07823fc54fa4fb8b91e67ec4fc2163e9..93ba7521d69b4b8ecee3dacb6395ab541dd25d48 100644 (file)
--- a/garmin.c
+++ b/garmin.c
@@ -284,6 +284,7 @@ waypt_read(void)
                waypt_add(wpt_tmp);
                GPS_Way_Del(&way[i]);
        }
+       xfree(way);
 }
 
 static
@@ -476,6 +477,8 @@ pvt_read(posn_status *posn_status)
 
        if (GPS_Command_Pvt_Get(&pvt_fd, &pvt)) {
                pvt2wpt(pvt, wpt);
+               GPS_Pvt_Del(&pvt);
+
                wpt->shortname = xstrdup("Position");
 
                if (gps_errno && posn_status) {
@@ -493,6 +496,7 @@ pvt_read(posn_status *posn_status)
                fatal(MYNAME ": Fatal error reading position.\n");
        }
 
+       waypt_free(wpt);
        GPS_Pvt_Del(&pvt);
 
        return NULL;
index 104f535c798fe7870c7d90bb37097819cd25901f..05aac8417981162113971f19e13afef1d9137a10 100644 (file)
@@ -3467,6 +3467,9 @@ drain_run_cmd(gpsdevh *fd)
            break;
        }
     }
+
+    GPS_Packet_Del(&tra);
+    GPS_Packet_Del(&rec);
   return 0;
 }
 
@@ -5967,18 +5970,25 @@ int32 GPS_A800_Get(gpsdevh **fd, GPS_PPvt_Data *packet)
     GPS_PPacket tra;
     GPS_PPacket rec;
 
-
     if(!(tra = GPS_Packet_New()) || !(rec = GPS_Packet_New()))
        return MEMORY_ERROR;
     
     
-    if(!GPS_Packet_Read(*fd, &rec))
+    if(!GPS_Packet_Read(*fd, &rec)) {
+       GPS_Packet_Del(&rec);
+       GPS_Packet_Del(&tra);
        return gps_errno;
+    }
     
-    if(!GPS_Send_Ack(*fd, &tra, &rec))
+    if(!GPS_Send_Ack(*fd, &tra, &rec)) {
+       GPS_Packet_Del(&rec);
+       GPS_Packet_Del(&tra);
        return gps_errno;
+    }
 
     if (rec->type != LINK_ID[gps_link_type].Pid_Pvt_Data) {
+       GPS_Packet_Del(&rec);
+       GPS_Packet_Del(&tra);
        return 0;
     }
     
@@ -5989,6 +5999,8 @@ int32 GPS_A800_Get(gpsdevh **fd, GPS_PPvt_Data *packet)
        break;
     default:
        GPS_Error("A800_GET: Unknown pvt protocol");
+       GPS_Packet_Del(&rec);
+       GPS_Packet_Del(&tra);
        return PROTOCOL_ERROR;
     }
 
index 225f35a474897d0f79cfc75161f699aed71c5a29..1847134462feea66dae84bc180ff34f7c3284c45 100644 (file)
@@ -104,6 +104,7 @@ gusb_teardown(gpsdevh *dh)
        if (udev) {
                usb_release_interface(udev, 0);
                usb_close(udev);
+               xfree(dh);
                udev = NULL;
        }
        return 0; 
diff --git a/kml.c b/kml.c
index aad6876789902801eb9da831136fda7ba9aa2551..cd92713a0834076c8b673d5065e50e665904257c 100644 (file)
--- a/kml.c
+++ b/kml.c
@@ -296,7 +296,7 @@ kml_wr_deinit(void)
                 * the file to be missing.  Windows readers will simply
                 * have to retry on this case.
                 */
-               unlink(posnfilename);
+               _unlink(posnfilename);
 #endif
                rename(posnfilenametmp, posnfilename);
                xfree(posnfilenametmp);
diff --git a/main.c b/main.c
index 9fcfc708160029913c3937986ca112b65e51aedd..f10caa190bf6cf5ad12a2c7a457195399cd7d337 100644 (file)
--- a/main.c
+++ b/main.c
@@ -565,8 +565,9 @@ main(int argc, char *argv[])
 
                while (1) {
                        posn_status status;
-                       waypoint *wpt = ivecs->position_ops.rd_position(&status);
+
                        status.request_terminate = 0;
+                       waypoint *wpt = ivecs->position_ops.rd_position(&status);
 
                        if (status.request_terminate) {
                                if (wpt) {